<template>
	<view>
		<view class="header">
			<view class="title">店员溯源</view>
			<view class="bottonGroup">
				<view class="botton focus">全部</view>
			</view>
		</view>

		<view style="width: 100%; position: absolute;">
			<view style="position: absolute; top: -40rpx; left: 50%; width: 95%; transform: translate(-50%, -3%);">
				<scroll-view scroll-y="true" @scrolltolower="lower" :style="{height: scrollViewHeight+'px'}"
					style="position: initial; bottom: 0; left: 0; right: 0; top: 0;" lower-threshold="200">
						<view v-for="item in dataList">
							<navigator :url="'/pages/staff/sourceOrder?clerkId=' + item.id + '&clerkName=' + item.nickname">
								<view style="width: 100%; float: left; border-radius: 30rpx; background-color: #fff; margin-top: 20rpx; padding-bottom: 10rpx;">
									<view style="padding: 20rpx 25rpx">
										<view style="width: 100%;">
											<view style="font-size: 34rpx; float: left;">
												<image :src="item.avatar_url" style="width: 100rpx; height: 100rpx;"></image>
											</view>
											<view style="float: left; padding: 20rpx;">{{item.nickname}}</view>
										</view>
									</view>
								</view>
							</navigator>
						</view>
				</scroll-view>
			</view>
		</view>

	</view>
</template>

<script>
	import * as userApi from '@/api/user'
	import * as api from '@/api/staff'
	import storage from '@/utils/storage'
	import config from '@/config'
	export default {
		components: {},
		data() {
			return {
				scrollViewHeight: '',
				dataList: [],
				page: 1,
				limit: 10
			}
		},
		onReady() {
			// 计算 scrollview 高度
			this.scrollViewHeight = uni.getSystemInfoSync().windowHeight - 40 - uni.getMenuButtonBoundingClientRect().top
		},
		onLoad() {
			this.getInfo();
			userApi.dashboard({
				activityId: storage.get('activityId')
			}).then(res => {
				// 获取店员二维码
				this.qrcodeUrl = config.apiUrl + 'activity/wxappQrcode' + 
					'?page=pages/clerk/api/join' +
					'&scene=' + 'staffUserId=' + res.data.id
			})
		},
		methods: {
			lower: function(e) {
				this.page = this.page + 1;
				this.getInfo();
			},
			getInfo: function() {
				api.clerkList({
					activityId: storage.get('activityId'),
					page: this.page,
					limit: this.limit
				}).then(res => {
					this.dataList = this.dataList.concat(res.data);
				})
			},
		},
		mounted() {

		}
	}
</script>

<style>
	page {
		background-color: #F6F7FB;
	}

	.header {
		background-color: #FFAC3E;
		position: inherit;
		width: 100%;
		height: 250rpx;
		border-radius: 0rpx 0rpx 20rpx 20rpx;
	}

	.header > .title {
		color: #fff;
		padding: 30rpx;
		font-size: 40rpx;
		font-weight: bold;
	}

	.header > .bottonGroup {
		width: 100%;
		position: initial;
		display: inline-table;
		text-align: center;
		margin-top: 0px;
	}

	.header > .bottonGroup view {
		font-size: 28rpx;
		float: left;
		padding: 5px 10px;
		margin-right: 5px;
		margin: 0px 0px 10px 10px;
		z-index: 999;
	}

	.header > .bottonGroup .botton {
		color: #FFFFFF;
	}

	.header > .bottonGroup .focus {
		border-bottom: 3px solid #FFFFFF;
		color: #FFFFFF;
	}

	/* 店员码展示 */
	.qrcodePop {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 1000;
	}

	.qrcodePop > .image_row {
		position: fixed;
		top: 50%;
		left: 50%;
		-webkit-transform: translate(-50%, -50%);
		transform: translate(-50%, -50%);
		width: 80%;
	}

	/* 悬浮关闭按钮 */
	.close {
		top: -90rpx;
		width: 50rpx;
		height: 50rpx;
		position: fixed;
		transform: translate(-50%, 30%);
	}

</style>